home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 February
/
Ahoy_Magazine_87-02_1987_Double_L.d64
/
Digit Decomp.
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
365b
|
15 lines
0 rem << cd38-4 >>
1 rem commodares problem #34-3:
2 print"digit decomposition"
3 rem solution by
4 rem donald pellegrini
5 rem
10 sum=0 : b=1e8 : flg=0
20 input n:if n>999999999 or n<0 or n-int(n)>0 then 20
30 if n<10 then print n;"=";n : goto 10
40 for j=1 to 9
50 c=int(n/b) : if c>0 then flg=1
60 if flg=1 then print c;:sum=sum+c:if j<9 then print"+";
70 n=n-c*b : b=b/10
80 next : print"=";sum : goto 10